﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace TDB.DBInternals
{
  public static class StoreManager
  {

    public static Dictionary<string, Dictionary<Type, IStore>> _stores = new Dictionary<string, Dictionary<Type, IStore>>();

    public static ObjectStore<T> GetStore<T>(string databasename)
    {
      Type tt = typeof(T);

      if (!_stores.ContainsKey(databasename))
        _stores.Add(databasename, new Dictionary<Type, IStore>());

      if (!_stores[databasename].ContainsKey(tt))
        _stores[databasename].Add(tt, new ObjectStore<T>(databasename));
      return (ObjectStore<T>)_stores[databasename][tt];
    }

    public static string[] Databases
    {
      get { return _stores.Keys.ToArray(); }
    }
  }
}
